function getCrossingSearchUrl(freeSearchOp, matchingAllTerms, matchingSearchHash) {
    return "/addama-rest/dudley-sample/path/datasource/YCR/search?" + freeSearchOp + matchingAllTerms +
           "&PROJECTION=crossingAlias" +
           "&PROJECTION=parentA" +
           "&PROJECTION=parentAlpha" +
           "&PROJECTION=progenyCount" +
           "&PROJECTION=progenyRange" +
           "&PROJECTION=crossingDate" +
           "&PROJECTION=crossingNote" +
           "&PROJECTION=crossingPlates" +
           "&PROJECTION=deletedCrossing" +
           "&PROJECTION=IGV" +
           "&PROJECTION=YCGSKeys" +
           "&PROJECTION=YCGSKey1" +
           "&PROJECTION=YCGSKey2" +
           "&PROJECTION=SNPs" +
           "&PROJECTION=SNPDupes" +
           "&PROJECTION=tetradCount" +
           matchingSearchHash;
}

function getKruglyakSearchUrl(freeSearchOp, matchingAllTerms, matchingSearchHash) {
    return "/addama-rest/dudley-sample/path/datasource/YKR/search?" + freeSearchOp + matchingAllTerms +
           "&PROJECTION=crossingAlias" +
           "&PROJECTION=parentA" +
           "&PROJECTION=parentAlpha" +
           "&PROJECTION=progenyCount" +
           "&PROJECTION=progenyRange" +
           "&PROJECTION=crossingDate" +
           "&PROJECTION=crossingNote" +
           "&PROJECTION=crossingPlates" +
           "&PROJECTION=deletedCrossing" +
           matchingSearchHash;
}

function getCrossingPagingColumns() {
    return [
        {
            name: 'indexNum',
            type: 'float'
        },
        {
            name: 'key'
        },
        {
            name: 'crossingAlias'
        },
        {
            name: 'parentA'
        },
        {
            name: 'parentAlpha'
        },
        {
            name: 'progenyCount'
        },
        {
            name: 'crossingDate'
        },
        {
            name: 'crossingNote'
        },
        {
            name: 'crossingPlates'
        },
        {
            name: 'progenyRange'
        },
        {
            name: 'IGV'
        },
        {
            name: 'YCGSKeys'
        },
        {
            name: 'YCGSKey1'
        },
        {
            name: 'YCGSKey2'
        },
        {
            name: 'SNPs'
        },
        {
            name: 'SNPDupes'
        },
        {
            name: 'tetradCount'
        }
    ];

}

function translateCrossingResultToJson(jsonSearchArray) {
    var jsonObj = [];
    var ycrKey = jsonSearchArray.name;
    jsonObj[0] = ycrKey.substring(4, ycrKey.length);
    jsonObj[1] = jsonSearchArray.name;
    jsonObj[2] = jsonSearchArray.crossingAlias;
    jsonObj[3] = jsonSearchArray.parentA;
    jsonObj[4] = jsonSearchArray.parentAlpha;
    jsonObj[5] = jsonSearchArray.progenyCount;
    jsonObj[6] = jsonSearchArray.crossingDate;
    jsonObj[7] = jsonSearchArray.crossingNote;
    jsonObj[8] = jsonSearchArray.crossingPlates;
    jsonObj[9] = jsonSearchArray.progenyRange;
    jsonObj[10] = jsonSearchArray.IGV;
    jsonObj[11] = jsonSearchArray.YCGSKeys;
    jsonObj[12] = jsonSearchArray.YCGSKey1;
    jsonObj[13] = jsonSearchArray.YCGSKey2;
    jsonObj[14] = jsonSearchArray.SNPs;
    jsonObj[15] = jsonSearchArray.SNPDupes;
    jsonObj[16] = jsonSearchArray.tetradCount;

    return jsonObj;
}

function initCrossingJson(crHash) {
    crHash.crossingAlias = undefined;
    crHash.parentA = undefined;
    crHash.parentAlpha = undefined;
}

function getCrossingSearchOptionsArray() {
    return [
        ['all', 'All'],
        ['key', 'key'],
        ['crossingAlias', 'crossingAlias'],
        ['parentA', 'parentA'],
        ['parentAlpha', 'parentAlpha'],
        ['progenyCount', 'progenyCount'],
        ['progenyRange', 'progenyRange'],
        ['crossingDate', 'crossingDate'],
        ['crossingNote', 'crossingNote'],
        ['crossingPlates', 'crossingPlates']
    ];
}

function getCrossingSearchColumnHeaders() {
    return  [
        {
            header: 'Index',
            width: 50,
            sortable: true,
            dataIndex: 'indexNum'
        },
        {
            id:'crossingKey',
            header: 'Key',
            width: 100,
            sortable: true,
            dataIndex: 'key'
        },
        {
            header: 'Alias',
            width: 125,
            sortable: true,
            dataIndex: 'crossingAlias'
        },
        {
            header: 'Parent A',
            width: 100,
            sortable: true,
            dataIndex: 'parentA'
        },
        {
            header: 'Parent alpha',
            width: 100,
            sortable: true,
            dataIndex: 'parentAlpha'
        },
        {
            header: 'Progeny Count',
            width: 100,
            sortable: true,
            dataIndex: 'progenyCount'
        },
        {
            header: 'Progeny Range',
            width: 100,
            dataIndex: 'progenyRange'
        },
        {
            header: 'Date',
            width: 100,
            sortable: true,
            dataIndex: 'crossingDate'
        },
        {
            header: 'Notes',
            hidden: true,
            dataIndex: 'crossingNote'
        },
        {
            header: 'Plates',
            hidden: true,
            dataIndex: 'crossingPlates'
        }

    ];
}

function populateCrossingJson(oHash, g) {
    oHash.name = g.getSelectionModel().getSelected().data.key;
    oHash.crossingAlias = g.getSelectionModel().getSelected().data.crossingAlias;
    oHash.parentA = g.getSelectionModel().getSelected().data.parentA;
    oHash.parentAlpha = g.getSelectionModel().getSelected().data.parentAlpha;
    oHash.progenyCount = g.getSelectionModel().getSelected().data.progenyCount;
    oHash.progenyRange = g.getSelectionModel().getSelected().data.progenyRange;
    oHash.crossingDate = g.getSelectionModel().getSelected().data.crossingDate;
    oHash.crossingNote = g.getSelectionModel().getSelected().data.crossingNote;
    oHash.crossingPlates = g.getSelectionModel().getSelected().data.crossingPlates;
    oHash.IGV = g.getSelectionModel().getSelected().data.IGV;
    oHash.YCGSKeys = g.getSelectionModel().getSelected().data.YCGSKeys;
    oHash.YCGSKey1 = g.getSelectionModel().getSelected().data.YCGSKey1;
    oHash.YCGSKey2 = g.getSelectionModel().getSelected().data.YCGSKey2;
    oHash.SNPs = g.getSelectionModel().getSelected().data.SNPs;
    oHash.SNPDupes = g.getSelectionModel().getSelected().data.SNPDupes;
    oHash.tetradCount = g.getSelectionModel().getSelected().data.tetradCount;
}

function validateCreateUpdateCrossing() {
    /*
     if (Ext.getCmp("crossingAliasId").getValue() == null || Ext.getCmp("crossingAliasId").getValue() == "") {
     Ext.Msg.alert('Error', 'Crossing name is required.');
     return false;
     } else if (Ext.getCmp("parentAId").getValue() == null || Ext.getCmp("parentAId").getValue() == "") {
     Ext.Msg.alert('Error', 'Parent A is required.');
     return false;
     } else if (Ext.getCmp("parentAlphaId").getValue() == null || Ext.getCmp("parentAlphaId").getValue() == "") {
     Ext.Msg.alert('Error', 'Parent Alpha is required.');
     return false;
     } else if (Ext.getCmp("progenyCountId").getValue() == null || Ext.getCmp("progenyCountId").getValue() == "") {
     Ext.Msg.alert('Error', 'Progeny Count is required.');
     return false;
     } else if (Ext.getCmp("crossingDateId").getValue() == null || Ext.getCmp("crossingDateId").getValue() == "") {
     Ext.Msg.alert('Error', 'Crossing Date is required.');
     return false;
     }*/

    return true;
}

function populateSingleCrossingViaSearch(strainHash, rec) {
    /*
        jsonObj[1] = jsonSearchArray.name;
    jsonObj[2] = jsonSearchArray.crossingAlias;
    jsonObj[3] = jsonSearchArray.parentA;
    jsonObj[4] = jsonSearchArray.parentAlpha;
    jsonObj[5] = jsonSearchArray.progenyCount;
    jsonObj[6] = jsonSearchArray.crossingDate;
    jsonObj[7] = jsonSearchArray.crossingNote;
    jsonObj[8] = jsonSearchArray.crossingPlates;
    jsonObj[9] = jsonSearchArray.progenyRange;
     */
    strainHash.name = rec[1];
    strainHash.crossingAlias = rec[2];
    strainHash.parentA = rec[3];
    strainHash.parentAlpha = rec[4];
    strainHash.progenyCount = rec[5];
    strainHash.crossingDate = rec[6];
    strainHash.crossingNote = rec[7];
    strainHash.crossingPlates = rec[8];
    strainHash.progenyRange = rec[9];
    strainHash.IGV = rec[10];
    strainHash.YCGSKeys = rec[11];
    strainHash.YCGSKey1 = rec[12];
    strainHash.YCGSKey2 = rec[13];
    strainHash.SNPs = rec[14];
    strainHash.SNPDupes = rec[15];
    strainHash.tetradCount = rec[16];
}


